草庐IT

HTML & CSS 设计原则

全部标签

javascript - 重新连接后未触发 socket.io 'connect' 或 'reconnect' 事件

我在使用Socket.io时遇到问题。代码很简单:varsocket=null;varsocketInit=false;//ifitistrue,usereconnect...functionconnect(){if(!socketInit){socket=io();socketInit=true;//attacheventhandlerssocket.on('connect',function(){console.log('connectfired!');});socket.on('disconnect',function(){console.log('disconnectfired

javascript - 服务器 : how to get "window", "location"和其他 "window"属性以及通常是浏览器对象上的浏览器代码?

我想在浏览器和服务器上都使用浏览器代码。我的代码基本上是React组件。我想浏览代码,得到一个编译表app.js并在浏览器和服务器上同时使用它://inabrowser//onaservervarApp=require('../assets/js/react/app');但据我所知,browserify不知道window对象。我不能在服务器端要求浏览器代码,抛出一个错误:if(window.location.pathname=='/foo'){^ReferenceError:windowisnotdefined代码如下:...manyReactcomponentsgohere...//

javascript - 未捕获的类型错误 : Cannot read property 'apply' of undefined phaser

未捕获的类型错误:无法读取未定义的属性“应用”??这是什么意思?我的意思是我尝试调试它,但无法找出问题所在。帮助将不胜感激。你们有什么需要帮助解决这个问题的,请随时问我。谢谢!JSBIN这是我的代码:vargame=newPhaser.Game(500,550,Phaser.CANVAS,'gameDiv');varCountDown={preload:function(){},update:function(){},render:function(){}}varplayer;varbullets;varenemies;vargreenEnemiesvarbulletTimer=0;v

javascript - react : get custom checkbox's checked attribute

我想用复选框进行一些自定义,它看起来像这样:所以我将我的自定义复选框包装到React组件中:require('../../less/ck-checkbox.less');varReact=require('react');varCkCheckbox=React.createClass({propTypes:{name:React.PropTypes.string,text:React.PropTypes.string,defaultChecked:React.PropTypes.bool,onChange:React.PropTypes.func},getDefaultProps:fu

javascript - 检查 CSS 选择器是否有效

我有一个供用户输入CSS选择器的字段,我想检查它是否有效(根据css3specification)。我尝试使用css3specification中的表达式正如anotherstackoverflowtopic中所建议的那样,但它不起作用-我构建的正则表达式与有效的选择器不匹配。我现在所拥有的只是:try{document.querySelector(selector);}catch(e){//handlebadinput}但这似乎不是一个好的解决方案-querySelector函数是为获取元素而设计的,检查选择器只是一个副作用。此外,它不提供有关选择器问题的任何信息。我正在寻找类似do

javascript - <span> 不能作为 <select> 的 child 出现在 react 中

我创建了一个选择下拉组件,我在react-redux应用程序中以redux形式使用它。下拉菜单效果很好,对性能没有影响,但在浏览器中我收到以下警告。Warning:validateDOMNesting(...):cannotappearasachildof.我不确定为什么会收到此错误,因为我没有传递任何元素。这是我用来创建选择下拉列表的代码(选项是一个包含每个选项属性的对象数组。option.text是一个将由用户查看的字符串值。所以它可能类似于“选项1”或“选项2”。)return({options.map((option)=>{return{option.text}})})关于为什

javascript - 本地修改数据的 Firebase 同步 : handling errors & global status

我有两个关于Firebasewebplatform的相关问题的synchronisationoflocally-modifieddatatotheserver:EveryclientsharingaFirebasedatabasemaintainsitsowninternalversionofanyactivedata.Whendataisupdatedorsaved,itiswrittentothislocalversionofthedatabase.TheFirebaseclientthensynchronizesthatdatawiththeFirebaseserversandw

javascript - jquery 中 window.resize() 和 window.on ('resize' ) 之间的区别

window.resize()和window.on('resize',function())有什么区别在jquery中? 最佳答案 来自jQuery页面.resize():Thismethodisashortcutfor.on('resize',handler).和.on()是:The.on()methodattacheseventhandlerstothecurrentlyselectedsetofelementsinthejQueryobject.AsofjQuery1.7,the.on()methodprovidesallfu

javascript - Excel 导出为 html 无法在 Excel 2016 中显示边框

我正在使用JavaScript将html导出到Excelxls文件,如下面的演示所示:http://js.do/sun21170/84913.我使用GoogleChrome来运行这个演示,但它也应该在Edge或IE或FireFox中运行。问题是,当我在Excel2016中打开导出的文件时,它显示没有任何边框,即使导出的html中有CSS来显示边框。问题:有没有办法在Excel中打开html文件时显示边框?在Excel中打开的相同html,在浏览器中呈现带有边框,因此边框的CSS是正确的。演示在http://js.do/sun21170/84913还显示了保存在Excel文件中的html

javascript - 使用 Angular1+ ES6 时, Controller 函数中的依赖注入(inject)未定义, Controller 作为类

我正在使用ES6类来定义我的Controller,所以这是语法,exportclassSearchBarController{constructor($log){'ngInject';$log.debug("Hello");}textTyped($log){$log.debug("changefired.");}}查看:因此,构造函数中的“Hello”已被正常记录。但是,typedText()函数中的“changefired”并未触发,因为显然未定义如何让我的类函数textTyped()访问$log服务?注意:如果我在构造函数中将$log分配给类属性,例如,this.logger=$l